package com.itbaizhan.test.exercise;

/**
 * 构造方法
 */
public class Point2 {
    double x,y;

    Point2(double _x,double _y){
        x = _x;
        y = _y;
    }

    public  double getDistance(Point2 p){
       /* double d = Math.sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
        return d;*/
        return  Math.sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
    }

    public static void main(String[] args) {
        Point2 p1 = new Point2(3,4);
        Point2 origin = new Point2(0,0);
        System.out.println(p1.getDistance(origin));
    }
}
